// pages/material/selectVipCard/selectVipCard.js
const Controllers = require('../../controllers/Controller.js').controller;
const formatTime3 = require('../../../utils/util.js').formatTime3
Page({
  data: {
    diyList:[],
    array:['套餐卡','充值卡']
  },
  onShow: function (options) {
    this.getDiyList()
  },
  getDiyList(){
    Controllers.shopList({shopId:wx.getStorageSync('shopId')}).then(res=>{
      this.setData({
        diyList:res.data
      })
    })
  },
  addcard(){
    wx.navigateTo({
      url: "/pages/diyActivity/adddiy/adddiy"
    });
  },
  //携带数据跳回上一页
  returnBychoose(e) {
    let pages = getCurrentPages();
    let prevPage = pages[pages.length - 2];  //上一个页面
    let chooseCard=this.data.chooseCard;
    prevPage.setData({
      chooseCard:chooseCard
    })
    wx.navigateBack({
  
    })
  },
  godesc(e){
    wx.navigateTo({
      url: "/pages/diyActivity/desc/desc?id="+e.currentTarget.dataset.id
    });
  },
  bindPickerChange(e){
    if(e.detail.value==0){
      wx.navigateTo({
        url: "/pages/diyActivity/adddiy/adddiy"
      });
    }else{
      wx.navigateTo({
        url: "/pages/diyActivity/addcard/addcard"
      });
    }
  },

  //获取选中vip卡和名字
  radioChange(e) {
    console.log(e);
    let ids=e.detail.value.split("/")[0];
    let name=e.detail.value.split("/")[1];

    this.setData({
      'chooseCard.ids':ids,
      'chooseCard.name':name
    })
  }
})